Chris Pollett >
Old Classes
> |
HW#5 --- last modified January 01 1970 00:00:00..Due date: May 13
Files to be submitted: Purpose: To become more familiar with sockets. To understand how CGI works. To write a simple perl program. To use a Properties file. Specification: Your goal in this last assignment is to write a simple web server in Java capable of serving HTML files without graphics and capable of executing CGI scripts. You can do this assignment on your machine at home if you install Perl. This assignment makes no use of the Tomcat server on iqaluit. Your server should be in the file MyWebServer.java. When it is run it reads in the properties file (use the Properties class) MyServerProperties.txt. This file should contain info on which port the server runs on, what is the path to Perl, the name of the machine, and what is the real location of the directories served by the server. Suppose the port number is set to 5432 and your URL is www.mymachine.com. Then your server uses a ServerSocket to listen to requests on this port. It should use threads so it can handle multiple requests at the same time. Your server should be able to handle requests for HTML documents in: http://www.machine.com:5432/public_html and handle requests for CGI scripts in: http://www.machine.com:5432/cgi-bin Your server only needs to be able to process HTTP GET requests. It can ignore all other requests. If the request is for an HTML document, your server just returns the document; if the request is for cgi script, use the class RunTime to exec a shell process with the appropriate runtime variables and run the script in question. The files test.html and test.cgi should be test files to prove your server works. test.html can be an html file of your choice that does not contain images. The file test.cgi should be a perl script that prints out the environment variables and implements a simple counter. Point Breakdown
|